//
//  CCConstraint.h
//  CCKit
//
//  Created by tucici on 2019/5/7.
//  Copyright © 2019 tucici. All rights reserved.
//
#define equal(value) equalTo(boxValue(@encode(__typeof__((value))), (value)))
#define coffset(value) offsetTo(boxValue(@encode(__typeof__((value))), (value)))


#import <Foundation/Foundation.h>
#import "CCLayoutConstraint.h"
#import "UIView+CCLayoutConstraint.h"
@class CCConstraint;
NS_ASSUME_NONNULL_BEGIN
@interface CCConstraint : NSObject
@property (nonatomic, assign) id firstItem;
@property (nonatomic, assign) CCAttribute firstAttribute;
@property (nonatomic, assign, nullable) id secondItem;
@property (nonatomic, assign) CCAttribute secondAttribute;
@property (nonatomic, assign) CCRelation relation;
@property (nonatomic, assign) CGFloat multiplier;
@property (nonatomic, assign) CGFloat constant;
@property (nonatomic, strong) NSMutableArray *firstAttributeArray;
@property (nonatomic, strong) NSMutableArray *secondAttributeArray;
@property (nonatomic, strong) NSMutableArray *constantArray;

/**
 链式函数方式，添加约束，以添加view为例，可以通过以下任一方式添加
 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
 view.size.equal(self.view);                                   //view.size=view.superview.size;
 view.size.equal(self.view.size);                              //view.size=view.superview.size;
 view.size.equal(self.view).with.coffset(CGSizeZero);          //view.size=view.superview.size;
 
 view.size.equal(CGSizeMake(100,100));                         //view.size=CGSizeMake(100,100);
 view.size.equal(nil).with.coffset(CGSizeMake(100,100));       //view.size=CGSizeMake(100,100);
 
 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
 view.cCenter.equal(self.view);                                //view.cCenter=view.superview.cCenter;
 view.cCenter.equal(self.view.cCenter);                        //view.cCenter=view.superview.cCenter;
 view.cCenter.equal(self.view).with.coffset(CGPointZero);      //view.cCenter=view.superview.cCenter;
 
 view.cCenter.equal(CGPointMake(100,100));                     //view.cCenter=CGPointMake(100,100);
 view.cCenter.equal(nil).with.coffset(CGPointMake(100,100));   //view.cCenter=CGPointMake(100,100);
 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
 
 */
- (CCConstraint * (^) (id obj))equalTo;
- (CCConstraint * (^) (id obj))equal;
- (CCConstraint *)with;

/**
 offsetTo的参数不能是nil/view/view.size....只能是以下参数类型:
 offset(100);                                                  //基本数据类型
 offset(CGSizeZero);                                           //CGSize类型
 offset(CGPointZero);                                          //CGPoint类型
 offset(UIEdgeInsets);                                         //UIEdgeInsets类型
 */
- (CCConstraint * (^) (id obj))offsetTo;
- (CCConstraint * (^) (id obj))coffset;


/**
 移除约束，例子: view.size.remove; 就移除了view的size相关的约束
 */
- (CCConstraint * (^) (void))remove;
id boxValue(const char *type, ...);

@end

NS_ASSUME_NONNULL_END
